Skip to content

Conversation

Zhou-Jiangcheng
Copy link

Fixed the Python output in the "Floating Point Numbers" section in the explanatory notes.

Fixed the Python output in the "Floating Point Numbers" section in the explanatory notes.
@Zhou-Jiangcheng
Copy link
Author

图片
The result in Python cell, in line 4
f = float(1 / 2) # 0.0
seems wrong in Python 3.11, numpy 1.26.4. It should be 0.5.
And I also tried float32(1/2), it returns the same result.

@Zhou-Jiangcheng Zhou-Jiangcheng changed the title fix the python output in floating section in "Python Fortran Rosetta Stone" page Fix the python output in floating section in "Python Fortran Rosetta Stone" page Sep 8, 2024
@Zhou-Jiangcheng Zhou-Jiangcheng changed the title Fix the python output in floating section in "Python Fortran Rosetta Stone" page Fix the python output in "Floating Point Numbers" section in "Python Fortran Rosetta Stone" page Sep 8, 2024
@zmoon
Copy link
Member

zmoon commented Sep 9, 2024

f = float(1 / 2) # 0.0
seems wrong in Python 3.11, numpy 1.26.4. It should be 0.5.

Yes, it was correct in Python 2, but for Python 3 the behavior of / for two ints changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants